#include "MessageTest.h"
#include "QuinceCore.h"
#include "Message.h"

MessageTest::MessageTest(QObject *parent) :
    QObject(parent)
{
}

void MessageTest::addContent()
{
    Message msg;
    QCOMPARE(msg.code().c_str(), "");
    msg.setCode("draw a line");
    QCOMPARE(msg.code().c_str(), "draw a line");

    msg.addContent("color", QColor(0, 0, 255));
    msg.addContent("text", QString("abc"));
    string readable = msg.toReadableString();
    QCOMPARE(readable.c_str(), "draw a line {color: #0000ff; text: abc; }");
    QColor clr = msg.getContent("color", QColor());
    QCOMPARE(clr, QColor(0, 0, 255));
    QString text;
    msg.getContent("text", QString(), text);
    QCOMPARE(text, QString("abc"));
}

QTEST_MAIN(MessageTest)
